Skip to content

Fix documented TextCalendar.format{week,monthname}() signatures - #159516

Merged
StanFromIreland merged 1 commit into
python:mainfrom
abhishekacharya200:docs-calendar-textcalendar-signatures
Oct 16, 2026
Merged

StanFromIreland merged 1 commit into
python:mainfrom
abhishekacharya200:docs-calendar-textcalendar-signatures

Conversation

@abhishekacharya200

Copy link
Copy Markdown
Contributor

The documented signatures of TextCalendar.formatweek() and TextCalendar.formatmonthname() don't match the code. In both methods width is a required argument:

def formatweek(self, theweek, width): ...
def formatmonthname(self, theyear, themonth, width, withyear=True): ...

The docs show formatweek(theweek, w=0) and formatmonthname(theyear, themonth, width=0, withyear=True). If you follow them, you get errors:

>>> import calendar
>>> c = calendar.TextCalendar()
>>> week = c.monthdays2calendar(2026, 10)[0]
>>> c.formatweek(week)
TypeError: TextCalendar.formatweek() missing 1 required positional argument: 'width'
>>> c.formatweek(week, w=3)
TypeError: TextCalendar.formatweek() got an unexpected keyword argument 'w'
>>> c.formatmonthname(2026, 10)
TypeError: TextCalendar.formatmonthname() missing 1 required positional argument: 'width'

This PR changes the two signatures to match the code and rewords the formatweek() description to use width. It only touches the docs, so I think it needs the "skip news" label.

Both methods require the width argument; the documented defaults (w=0 and width=0) do not exist, and formatweek() has no 'w' parameter.
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #35189190 | 📁 Comparing 3a162e2 against main (21a36aa)

  🔍 Preview build  

1 file changed
± library/calendar.html

@StanFromIreland StanFromIreland changed the title Docs: Fix TextCalendar.formatweek() and formatmonthname() signatures Fix documented TextCalendar.format{week,monthname}() signatures Oct 16, 2026
@StanFromIreland
StanFromIreland merged commit 9cb7a5b into python:main Oct 16, 2026
43 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Oct 16, 2026
@StanFromIreland StanFromIreland added awaiting merge needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Oct 16, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @abhishekacharya200 for the PR, and @StanFromIreland for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @abhishekacharya200 for the PR, and @StanFromIreland for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Oct 16, 2026

Copy link
Copy Markdown

GH-159568 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Oct 16, 2026
@bedevere-app

bedevere-app Bot commented Oct 16, 2026

Copy link
Copy Markdown

GH-159569 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Oct 16, 2026
StanFromIreland pushed a commit that referenced this pull request Oct 17, 2026
…res (GH-159516) (#159569)

(cherry picked from commit 9cb7a5b)

Co-authored-by: Abhishek Acharya <118182738+abhishekacharya200@users.noreply.github.com>
StanFromIreland pushed a commit that referenced this pull request Oct 17, 2026
…res (GH-159516) (#159568)

(cherry picked from commit 9cb7a5b)

Co-authored-by: Abhishek Acharya <118182738+abhishekacharya200@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants